﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using WiMo.Games.Drawables;

namespace WiMo.Games.WM5.Drawables
{
    public class Ellipse : SpriteShapeBase
    {
        public Ellipse()
        {
            ShapeType = ShapeType.Ellipse;
            CollisionShape = CollisionShapes.Sphere;
        }             

        public override WiMo.Games.Size Size
        {
            get { return new Size((int)(_size.Width * Scale.X), (int)(_size.Height * Scale.Y)); ; }
            set 
            {
                CollisionDetectionPoints.Clear();

                _size = value;

                var rads =  2.0f * Math.PI / 8.0f;
                var radius = _size.Width / 2;

                for (var idx = 0.0f; idx < 8f; ++idx)
                    CollisionDetectionPoints.Add(new Location(Math.Sin(rads * idx) * radius, Math.Cos(rads * idx) * radius)); 
            }
        }

        public override void Render(IDisplay display)
        {
            display.Render(this);
        }

        public override void Dispose()
        {

        }
    }
}
